aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/scope-prompt/[scopes]/+server.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/scope-prompt/[scopes]/+server.ts')
-rw-r--r--src/routes/scope-prompt/[scopes]/+server.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/routes/scope-prompt/[scopes]/+server.ts b/src/routes/scope-prompt/[scopes]/+server.ts
new file mode 100644
index 0000000..f919b9c
--- /dev/null
+++ b/src/routes/scope-prompt/[scopes]/+server.ts
@@ -0,0 +1,21 @@
+import { base } from '$app/paths';
+import { checkScope } from '$lib/auth';
+import { error, redirect } from '@sveltejs/kit';
+
+export const GET = async (e) => {
+ const scopes = e.params.scopes
+ .split(' ')
+ .flatMap((v) => v.split(','))
+ .flatMap((v) => v.split('+'))
+ .filter((v) => v);
+ if (
+ checkScope(
+ await e.locals.auth(),
+ scopes,
+ true,
+ base + '/scope-prompt/ok/if/' + scopes.join(',')
+ )
+ )
+ throw redirect(303, base + '/scope-prompt/ok');
+ else throw error(500, 'In server mode, this branch should be unreachable');
+};